package com.shujia.io_.three;

import org.junit.Test;

import java.io.*;

public class Exer2 {


    @Test
    public void test4() throws Exception {
        InputStreamReader isr = new InputStreamReader(
                new FileInputStream("C:\\Users\\Thinkpad\\Desktop\\c.txt"), "GBK");
        char[] chs = new char[60];
        int len;
        while ((len = isr.read(chs)) != -1) {
            System.out.println(new String(chs, 0, len));
        }

    }

    @Test
    public void test2() {
        try (FileReader fr = new FileReader("file\\《雪中悍刀行》.txt");
             FileWriter fw = new FileWriter("file\\xiaoshuo\\雪中悍刀行.mp4")) {

            int data;
            while ((data = fr.read()) != -1) {
                fw.write(data);
                fw.flush();
            }

            fw.close();
            fr.close();


        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    @Test
    public void test1() {
        try (FileReader fr = new FileReader("file\\《雪中悍刀行》.txt");
             FileWriter fw = new FileWriter("file\\xiaoshuo\\雪中悍刀行.mp4")) {

            char[] chs = new char[60];
            int len;
            while ((len = fr.read(chs)) != -1) {
                fw.write(chs, 0, len);
                fw.flush();
            }

            fw.close();
            fr.close();


        } catch (IOException e) {
            e.printStackTrace();
        }


    }


    @Test
    public void test0() {
        try (InputStream is = new FileInputStream("file\\鹿鼎记I_hd.mp4");
             OutputStream os = new FileOutputStream("file\\mp4\\ldj.mp4")) {

            int data;
            while ((data = is.read()) != -1) {
                os.write(data);
                os.flush();
            }

            os.close();
            is.close();


        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
